package com.utils;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Config {
	
	private static final String CONFIG_PROPERTIES = "config.properties";
	public static String port = getProperties("port");
	public static String host = getProperties("host");
	
	private static String getProperties(String key) {
		if ((port == null || port.isEmpty()) || (host == null || host.isEmpty())) {
			Properties properties = new Properties();
			try {
				properties.load(new FileInputStream(new File(CONFIG_PROPERTIES)));
				return properties.getProperty(key);
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return key.equals("port") ? port : host;
	}
	
	private static void isEmoji(String input) {
		Pattern pattern = Pattern.compile("^[!@#$%^&*()_+~|<>A-Za-z￥\\u4e00-\\u9fa5\\d\\p{P}\\p{S}\\p{N}‘’“”ns*r]*$");
		Matcher matcher = pattern.matcher(input);
		System.out.println(matcher.matches());
	}

}
